# -*- coding: utf-8 -*-
# Version:python3.7
# Date:2020/6/9 15:42
import base64,io,xlwt
from odoo import api, fields, models, _
class WizardBackInfo(models.TransientModel):
    _name = "wizard.back.info"
    _description = "撤销信息"
    # _auto = False
    message = fields.Text(string="退回原因", help="请填写退回原因")
    def back_btn_comfirm(self):
        record_id = self._context.get("id")
        model_name = self._context.get("model_name")
        state_value = self._context.get("state")
        obj_record = self.env[model_name].search([('id','=',record_id)]).sudo()
        obj_record.message_post(body="退回原因:"+self.message, subtype="mail.mt_note")
        obj_record.write({'state': state_value,})
        return {
            'name': self.env[model_name]._description,
            'type': 'ir.actions.act_window',
            'res_model': model_name,
            'views': [[False, 'tree'], [False, 'form']],
            'target': 'main',
            'context': dict(
                self.env.context,
            ),
        }
